<?php

class CargoModel extends Database {
    
    const TABLE = "funcionario_cargo";
    
    const ID = "id";
    const NOME = "nome_cargo";
    
    const COD_COBRADOR = 2;
    const COD_GERENTE = 4;
    
    public function select($fields = " * ", $condition = null, $limit = null) {
        if(is_array($fields)) $fields = implode (",", $fields);
        $res = parent::select(self::TABLE, $fields, $condition, $limit);
        $ana = $this->getAnnalisses();
        $cargos = array();
        while(($row = $ana->fetchObject($res)) !== false) {
            $cargo = new Cargo( isset($row->{self::ID})? $row->{self::ID} : 0, 
                                isset($row->{self::NOME})? ($row->{self::NOME}): "" );
            $cargos[] = $cargo;		
        }
        return $cargos;
    }
    
}
?>
